﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Hospital_HospitalPurList : System.Web.UI.Page, HZ.MBSM.BLL.TraDes
{
    public Int64 HPLProject;
    public Int64 HPLHospitalId;
    String HPLHospName;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            HPLProject = SysFun.ToInt(SysFun.IsSQL(Request.QueryString["ProjectId"]));

            HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
            if (_Account != null)
            {
                String StrSql, HsPId;
                HPLHospitalId = SysFun.ToLong(_Account.AccountId);
                HPLHospName = _Account.DWName;
                //<!--撤废品种
                if (Request.Form["del"] == "撤废品种" && Request.Form["chk"] != null)
                {
                    HsPId = Request.Form["chk"];
                    Db db = new Db();
                    StrSql = "@if not exists(select * from HospitalPurchase where State='2' and HsPId in (" + HsPId + ") ) Update HospitalPurchase Set State='0' Where HsPId in (" + HsPId + ")";
                    //将选中的商品中没开始交易的商品从医院交易目录中删除；

                    StrSql += "@delete HospitalPurchase where  projectid=" + HPLProject + " and accountid_yy=" + HPLHospitalId + " and HsPId in (" + HsPId + ") and supplygoodsid not in(select supplygoodsid from BuyPlanGoods where  accountid_yy=" + HPLHospitalId + ")";
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新，删除", "HospitalPurchase", StrSql, "..Hospital/HospitalPurList.aspx");
                    db.ExecuteTransaction(StrSql.Substring(1).Split(new char[] { '@' }), 30);
                    db.Close();
                }
                //撤废品种-->

                //<!--恢复已撤废品种


                if (Request.Form["Return"] == "恢复已撤废品种" && Request.Form["chk"] != null)
                {
                    HsPId = Request.Form["chk"];
                    Db db = new Db();
                    StrSql = "if not exists(select * from HospitalPurchase where State='2' and HsPId in (" + HsPId + ") ) Update HospitalPurchase Set State='1' Where HsPId in (" + HsPId + ")";
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "HospitalPurchase", StrSql, "..Hospital/HospitalPurList.aspx");
                    db.Command(StrSql);
                    db.Close();
                }
                //恢复已撤废品种-->

                //<!--保存填写的数据

                if (Request.Form["BtnConfirm1"] == "保存填写的数据")
                {
                    string IdHao = "", jiaoyijia, cgl, HPLAccountid_PS, HPLCompanyName_PS, strSql;
                    IdHao = SysFun.ToTrim(Request.Form["IdHao"]);
                    jiaoyijia = Request.Form["PurchasePrice"];
                    cgl = Request.Form["PlanPurNum"];
                    Db db = new Db();
                    if (IdHao != "")
                    {
                        string[] SGID = IdHao.Length == 0 ? new string[] { "" } : IdHao.Substring(0).Split(new char[] { ',' });
                        //string[] PurPrice = jiaoyijia.Length == 0 ? new string[] { "" } : jiaoyijia.Substring(0).Split(new char[] { ',' });
                        string[] PlanPurNum = cgl.Length == 0 ? new string[] { "" } : cgl.Substring(0).Split(new char[] { ',' });

                        int nNumber = 0;
                        strSql = "";
                        for (int i = 0; i < SGID.Length; i++)
                        {
                            nNumber++;
                            HPLAccountid_PS = Request.Form["txtAccountId_PS" + SGID[i]];
                            HPLCompanyName_PS = Request.Form["txtCompanyName_PS" + SGID[i]];
                            strSql += "@" + "Update HospitalPurchase set PlanPurNum=" + SysFun.ToInt(PlanPurNum[i]) + ",Accountid_PS=" + HPLAccountid_PS + " where HsPId=" + SGID[i].ToString();
                            //if (SysFun.IsNumeric(PurPrice[i]))
                            //{
                            //    strSql += "@" + "Update HospitalPurchase set PlanPurNum='" + SysFun.ToInt(PlanPurNum[i]) + "',PurchasePrice='" + PurPrice[i] + "',Accountid_PS2='" + HPLAccountid_PS + "' where HsPId=" + SGID[i].ToString();
                            //}
                            //else
                            //{
                            //    Response.Write("<script>alert('价格" + PurPrice[i].ToString() + "输入有误！');</script>");

                            //}

                        }

                        if ((strSql.Length > 0) && (nNumber == SGID.Length))
                        {
                            db.ExecuteTransaction(strSql.Substring(1).Split(new char[] { '@' }), 30);
                            HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "更新", "HospitalPurchase", strSql, "..Hospital/HospitalPurList.aspx");
                            Response.Write("<script>alert('数据保存成功！');</script>");
                        }
                    }
                    db.Close();

                }
                //删除选错的药品

                //if (Request.Form["Subdel"] == "删除采购目录的药品" && Request.Form["chk_del"] != null)
                //{
                //    HsPId = Request.Form["chk_del"];
                //    Db db = new Db();
                //    StrSql = "delete HospitalPurchase Where HsPId in (" + HsPId + ")";
                //    db.Command(StrSql);
                //    db.Close();
                //}
                //保存填写的数据-->
                showGridView();
            }
        }

    }

    public void showGridView()
    {
        string priceTitle = "挂网价";
        string field_lsj = "";
        string field_name = "";

        switch (HPLProject.ToString())
        {
            case "8":
                field_name = "最高零售价";
                field_lsj = ",RetailPrice as " + field_name;
                break;
            case "9":
                priceTitle = "最高零售价";
                break;
            case "10":
                priceTitle = "最高限价";
                field_name = "最高零售价";
                field_lsj = ",RetailPrice as " + field_name;

                break;
            case "11":
                priceTitle = "最高零售价";
                break;
            case "12":
                priceTitle = "最高零售价";
                break;

        }
        int i = 0;
        string strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "PurchaseTable";                                               //要查询的表明
        dbPage.Key = "HsPId";                                            //表的主键    
        dbPage.Where = strConditions;                                           //查询条件
        dbPage.SelectField = "SupplyGoodsId,Projectid,CompanyName_SC,HsPId,GoodsId,State,CompanyName_PS,ProductName,GoodsName,Medicinemodel,Outlookc,Factor,CASE QualityLevels " + ConfigurationManager.AppSettings["QualityLevels"].ToString() + " END AS QualityLevels,GoodsState,BidPrice,PlanPurNum,AccountId_PS1,CompanyName_PS1,AccountId_PS,CompanyName_PS,AccountId_TB,CompanyName_TB,IsNull(Unit,'')+'/'+IsNull(PackUnit,'') As Pack1,UserCode_PS" + field_lsj;
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 10;                                                    //没有显示记录条数   
        dbPage.OrderBy = "ProductCode,HsPId";//排序字段
        System.Text.StringBuilder strHtml = new System.Text.StringBuilder();




        strHtml.Append("<table width='100%' border='0.5' align='left' cellpadding='2' cellspacing='1'  class='table_table' id='Mytable'>");
        strHtml.Append("<tr>");
        strHtml.Append("<td width='4%'>流水号</td>");
        strHtml.Append("<td width='8%'>通用名</td>");
        strHtml.Append("<td width='5%'>商品名</td>");
        strHtml.Append("<td nowrap>剂型</td>");
        strHtml.Append("<td nowrap>规格</td>");
        strHtml.Append("<td width='5%'>转换系数</td>");
        strHtml.Append("<td width='5%'>包装规格</td>");
        strHtml.Append("<td width='4%'>质量层次</td>");
        if (field_lsj != "")
        {
            strHtml.Append("<td    width='6%'>" + field_name + "</td>");
        }
        strHtml.Append("<td width='4%'>采购目录状态</td>");
        strHtml.Append("<td>" + priceTitle + "</td>");
        strHtml.Append("<td>采购价</td>");
        strHtml.Append("<td>预采购量</td>");
        strHtml.Append("<td width='9%'>生产企业</td>");
        strHtml.Append("<td width='9%'>一级配送企业</td>");
        strHtml.Append("<td width='9%'>二级配送企业</td>");
        strHtml.Append("<td width='9%'>中标人</td>");
        strHtml.Append("<td style='display:none'>配送企业注册号</td>");
        strHtml.Append("<td width='4%'>采购状态</td>");
        strHtml.Append("<td width='4%'>撤废/恢复目录</td>");
        // strHtml.Append("<td>删除目录</td>");
        strHtml.Append("<td  width='4%'>修改配送企业</td>");
        strHtml.Append("</tr>");
        System.Data.IDataReader dr = dbPage.ExecuteReader();

        while (dr.Read())
        {
            if (i == 0)
            {
                strHtml.Append("<tr class='table_td'>");
                i++;
            }
            else
            {
                strHtml.Append("<tr class='table_td2'>");
                i--;
            }
            //strHtml.Append("<td width='4%'>" + dr["GoodsId"].ToString() + "</td>");
            strHtml.Append("<td align='center'><a href='RevisionHosPur.aspx?HsPId=" + dr["HsPId"] + "&SupplyGoodsId=" + dr["SupplyGoodsId"] + "&Projectid=" + dr["Projectid"] + "' target='_blank'>" + dr["GoodsId"].ToString() + "</a></td>");
            strHtml.Append("<td>" + dr["ProductName"].ToString() + "</td>");
            strHtml.Append("<td>" + dr["GoodsName"].ToString() + "</td>");
            strHtml.Append("<td><input name='txtCompanyName_PS" + dr["HsPId"].ToString() + "' type='hidden' value='" + SysFun.ToTrim(dr["CompanyName_PS"].ToString()) + "'>" + dr["Medicinemodel"].ToString() + "</td>");
            strHtml.Append("<td>" + dr["Outlookc"].ToString() + "</td>");
            strHtml.Append("<td>" + dr["Factor"].ToString() + "</td>");
            strHtml.Append("<td>" + dr["Pack1"].ToString() + "</td>");
            strHtml.Append("<td>" + dr["QualityLevels"].ToString() + "</td>");
            if (field_lsj != "")
            {
                strHtml.Append("<td    width='6%'>" + dr[field_name].ToString() + "</td>");
            }
            string _strGoodsState = dr["GoodsState"].ToString();
            switch (_strGoodsState)
            {
                //0 原中标商品 1 自行采购  2  22种降价 3 人血蛋白 4 重点监控 默认为‘0’

                case "0":
                    strHtml.Append("<td>原中标</td>");
                    strHtml.Append("<td>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "</td>");

                    strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "</td>");
                    //strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'><input type='text' size=6 name='PurchasePrice'  onblur=\"javascript:if(!/^[0-9]+(.[0-9]{1,2})?$/.test(this.value)){alert('流水号" + dr["GoodsId"].ToString() + "请输入正确价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "};if(this.value>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "){alert('对不起,流水号" + dr["GoodsId"].ToString() + "你输入的价格大于中标价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "}\" NumericOnly='PurchasePrice' NotNull='PurchasePrice'  value='" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "'title='中标价为：" + dr["BidPrice"].ToString() + "' ></td>");
                    break;
                case "1":
                    strHtml.Append("<td>自行采购</td>");
                    strHtml.Append("<td>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "</td>");
                    strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'></td>");

                    //strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'><input type='text' size=6 name='PurchasePrice'  onblur=\"javascript:if(!/^[0-9]+(.[0-9]{1,2})?$/.test(this.value)){alert('流水号" + dr["GoodsId"].ToString() + "请输入正确价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "};\" NumericOnly='PurchasePrice' NotNull='PurchasePrice'  value='" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "'title='中标价为：" + dr["BidPrice"].ToString() + "' ></td>");

                    break;
                case "2":
                    strHtml.Append("<td>22种降价</td>");
                    strHtml.Append("<td>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "</td>");
                    strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "</td>");
                    //strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'><input type='text' size=6 name='PurchasePrice'  onblur=\"javascript:if(!/^[0-9]+(.[0-9]{1,2})?$/.test(this.value)){alert('流水号" + dr["GoodsId"].ToString() + "请输入正确价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "};if(this.value>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "){alert('对不起,流水号" + dr["GoodsId"].ToString() + "你输入的价格大于中标价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "}\" NumericOnly='PurchasePrice' NotNull='PurchasePrice'  value='" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "'title='中标价为：" + dr["BidPrice"].ToString() + "' ></td>");
                    break;
                case "3":
                    strHtml.Append("<td>血液制品</td>");
                    strHtml.Append("<td></td>");
                    strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'></td>");
                    //strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'><input type='text' size=6 name='PurchasePrice'  onblur=\"javascript:if(!/^[0-9]+(.[0-9]{1,2})?$/.test(this.value)){alert('流水号" + dr["GoodsId"].ToString() + "请输入正确价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "};if(this.value>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "){alert('对不起,流水号" + dr["GoodsId"].ToString() + "你输入的价格大于中标价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "}\" NumericOnly='PurchasePrice' NotNull='PurchasePrice'  value='" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "'title='中标价为：" + dr["BidPrice"].ToString() + "' ></td>");
                    break;
                case "4":
                    strHtml.Append("<td>重点监控</td>");
                    strHtml.Append("<td>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "</td>");
                    strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'></td>");
                    //strHtml.Append("<td><input name='IdHao' type='hidden' value='" + dr["HsPId"].ToString() + "'><input type='text' size=6 name='PurchasePrice'  onblur=\"javascript:if(!/^[0-9]+(.[0-9]{1,2})?$/.test(this.value)){alert('流水号" + dr["GoodsId"].ToString() + "请输入正确价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "};if(this.value>" + SysFun.OutNum(dr["BidPrice"].ToString(), 2) + "){alert('对不起,流水号" + dr["GoodsId"].ToString() + "你输入的价格大于中标价格！');this.value=" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "}\" NumericOnly='PurchasePrice' NotNull='PurchasePrice'  value='" + SysFun.OutNum(dr["PurchasePrice"].ToString(), 2) + "'title='中标价为：" + dr["BidPrice"].ToString() + "' ></td>");
                    break;

            }

            if (Convert.IsDBNull(dr["PlanPurNum"]))
            {
                strHtml.Append("<td><input type='text' size=6 name='PlanPurNum' onblur=\"javascript:if(!/^\\d+$/.test(this.value)){alert('流水号" + dr["GoodsId"] + "请输入正确采购量！');this.focus();return false;}\" NumericOnly='PlanPurNum' NotNull='PlanPurNum' value='0' ></td>");
            }
            else
            {
                strHtml.Append("<td><input type='text' size=6 name='PlanPurNum' onblur=\"javascript:if(!/^\\d+$/.test(this.value)){alert('流水号" + dr["GoodsId"] + "请输入正确采购量！');this.focus();return false;}\" NumericOnly='PlanPurNum' NotNull='PlanPurNum' value='" + SysFun.OutNum(dr["PlanPurNum"].ToString(), 2) + "' ></td>");
            }
            strHtml.Append("<td><input name='txtAccountId_PS" + dr["HsPId"].ToString() + "' type='hidden' value='" + SysFun.ToInt(dr["AccountId_PS"].ToString()) + "'>" + dr["CompanyName_SC"].ToString() + "</td>");
            strHtml.Append("<td><a href='../agency/company_xq.aspx?&Accountid_PS=" + dr["AccountId_PS1"].ToString() + "' target='blank' target='_blank'>" + dr["CompanyName_PS1"].ToString() + "</a></td>");
            strHtml.Append("<td><a href='../agency/company_xq.aspx?&Accountid_PS=" + dr["AccountId_PS"].ToString() + "' target='blank' target='_blank'>" + dr["CompanyName_PS"].ToString() + "</a></td>");
            strHtml.Append("<td><a href='../agency/company_xq.aspx?&Accountid_PS=" + dr["AccountId_TB"].ToString() + "' target='blank' target='_blank'>" + dr["CompanyName_TB"].ToString() + "</a></td>");

            strHtml.Append("<td style='display:none'>" + dr["UserCode_PS"].ToString() + "</td>");


            strHtml.Append("<td>" + dr["State"].ToString() + "</td>");
            if (dr["State"].ToString() == "招办撤废")
            {
                strHtml.Append("<td></td>");
            }
            else
            {
                strHtml.Append("<td><input name='chk' type='checkbox' value='" + dr["HsPId"].ToString() + "'></td>");
            }


            //strHtml.Append("<td><input name='chk_del' type='checkbox' value='" + dr["HsPId"].ToString() + "'></td>");
            Int64 AccountId_PS1 = SysFun.ToLong(dr["AccountId_PS1"].ToString());
            strHtml.Append("<td align='center' id=\"MyTD123\" onclick='Sel_PS(" + dr["HsPId"].ToString() + ")' Style=\"color:Red;cursor:hand\">修改</a></td>");
            strHtml.Append("</tr>");
        }
        strHtml.Append("</table>");
        Label1.Text = strHtml.ToString();


        dr.Close();
        dr.Dispose();
        dbPage.Db.Close();
        db.Close();

        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键

        //this.DbPageFlip2.DbPage = dbPage;


    }

    public string fctConditions()
    {
        string _strTemp = " ProjectId='" + HPLProject.ToString() + "' And AccountId_YY='" + HPLHospitalId.ToString() + "' And";
        string _strStatus = SysFun.ToTrim(DLStatus.SelectedValue);// 医院采购状态

        switch (_strStatus)
        {
            case "全部"://

                break;
            case "撤废目录"://
                _strTemp += " (State='撤废' or State='招办撤废') And";
                break;
            case "正常采购":
                _strTemp += " State='正常采购' And";
                break;
        }

        //总配送目录表中已撤废的在医院目录表中还没撤废的品种

        if (CHbdel.Checked == true)
        {
            _strTemp += " IsUse=0 And State='正常采购' And";
        }

        //未确定配送企业的品种
        if (Chkps.Checked == true)
        {
            _strTemp += " (CompanyName_PS is null or CompanyName_PS='')  And";
        }

        //未填写预采购量的品种
        if (ChkNum.Checked == true)
        {
            _strTemp += " (PlanPurNum=0 or PlanPurNum is Null) And";
        }

        //通用名或拼音码

        string _strProudctName = txtProudctName.Text.ToString();
        if (_strProudctName != "")
        {
            _strTemp += " (ProductName like '%" + _strProudctName + "%' or Product_SpellingCode like '%" + _strProudctName + "%') and";
        }

        //规格
        string _strOutlookc = txtOutLookc.Text.ToString();
        if (_strOutlookc != "")
        {
            _strTemp += " outlookc like '%" + _strOutlookc + "%' and";
        }

        //流水号

        string _strGoodsId = SysFun.ToTrim(txtGoodsId.Text);
        if (_strGoodsId != "")
        {
            _strTemp += " GoodsId = '" + _strGoodsId + "' and";
        }

        //生产企业名称
        string _strCompanyName_SC = txtCompanyName_SC.Text.ToString();
        if (_strCompanyName_SC != "")
        {
            _strTemp += " CompanyName_SC like '%" + _strCompanyName_SC + "%' and";
        }

        //生产企业编码
        string _strUserCode_SC = txtUserCode_SC.Text.ToString();
        if (_strUserCode_SC != "")
        {
            _strTemp += " UserCode_SC like '%" + _strUserCode_SC + "%' and";
        }

        //配送企业名称

        string _strCompanyName_PS = txtCompanyName_PS.Text.ToString();
        if (_strCompanyName_PS != "")
        {
            _strTemp += " CompanyName_PS like '%" + _strCompanyName_PS + "%' And";
        }

        //配送企业编码

        string _strUserCode_PS = txtUserCode_PS.Text.ToString();
        if (_strUserCode_PS != "")
        {
            _strTemp += " UserCode_PS like '%" + _strUserCode_PS + "%' And";
        }

        //商品名

        string _strGoodsName = txtGoodsName.Text.ToString();
        if (_strGoodsName != "")
        {
            _strTemp += " GoodsName like '%" + _strGoodsName + "%' and";
        }
        if (_strTemp != "")
        {
            _strTemp = "  " + _strTemp.Substring(0, _strTemp.Length - 3);
        }
        return _strTemp;

    }

    public void Print()
    {
        Response.Clear();
        Response.Buffer = true;
        Response.Charset = "GB2312";
        // 添加头信息，为"文件下载/另存为"对话框指定默认文件名
        Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(HPLHospName + "采购目录.xls"));
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
        Response.ContentType = "application/ms-excel";
        this.EnableViewState = false;
        System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
        this.GridView1.RenderControl(oHtmlTextWriter);

        // 把文件流发送到客户端 
        Response.Write(oStringWriter.ToString());
        // 停止页面的执行

        Response.End();
    }

    #region TraDes 成员

    public string Name
    {
        get { return "维护采购目录"; }
    }

    public string Describe
    {
        get { return ""; }
    }

    public string ParentName
    {
        get { return "交易数据管理"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHospitale);
            return _AccountType;
        }
    }

    #endregion
    protected void Button1_Click(object sender, EventArgs e)
    {
        string field_lsj = "";
        string field_name = "";
        string priceTitle = "挂网价";
        switch (HPLProject.ToString())
        {
            case "8":
                field_name = "最高零售价";
                field_lsj = ",RetailPrice as " + field_name;
                break;
            case "9":
                priceTitle = "最高零售价";
                break;
            case "10":
                priceTitle = "最高限价";
                field_name = "最高零售价";
                field_lsj = ",RetailPrice as " + field_name;

                break;
            case "11":
                break;

        }
        String SQL;
        SQL = "Select Goodsid As 流水号,ProductName As 通用名,GoodsName As 商品名,MedicineModel As 剂型,OutLookc AS 规格,Factor As 转换系数,IsNull(Unit,'')+'/'+IsNull(PackUnit,'') As 包装规格,CASE QualityLevels " + ConfigurationManager.AppSettings["QualityLevels"].ToString() + " END AS 质量层次" + field_lsj + ", Convert(numeric(20,2),BidPrice)  AS  " + priceTitle + " ,PurchasePrice As 采购价,PlanPurNum As 预采购量,CompanyName_SC As 生产企业,CompanyName_Ps As 配送企业,CompanyName_TB As 中标人 From PurchaseTable Where ProjectId='" + HPLProject.ToString() + "'and State='正常采购' And AccountId_YY='" + HPLHospitalId.ToString() + "'";
        Db db = new Db();
        System.Data.IDataReader dr;
        dr = db.DataReader(SQL);
        this.GridView1.DataSource = dr;
        this.GridView1.DataBind();
        db.Close();
        dr.Close();
        dr.Dispose();
        Print();
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
        //OverRide　为了使导出成Excel可行！

    }
}
